// 购物车仓库
import http from '@/serveies/api/request'
import { Toast, MessageBox } from 'mint-ui'
export default {
  state: {
    list: []
  },
  getters: {
  },
  mutations: {
    initGetData (state, pathArr) {
      state.list = pathArr
    },
    deleteAddress (state, id) {
      state.list = state.list.filter(v => {
        return v.id !== id
      })
    }
  },
  actions: {
    deleteAddressFn ({ commit }, id) {
      MessageBox({
        message: '确定要删除吗?',
        showCancelButton: true
      }).then(res => {
        http
          .$axios({
            url: '/api/deleteAddress',
            method: 'post',
            headers: {
              token: true
            },
            data: {
              id
            }
          })
          .then((res) => {
            if (res.success) {
              commit('deleteAddress', id)
              Toast(res.msg)
            }
          })
      })
    }
  }
}
